import axios from './axios'
import api from './api'
import moment from "moment";

// 上报定位
export const reportLocation = (data) => {
  const sendTime = new Date().getTime() || moment().valueOf() || 1
  return axios({
    url: api.addPosition,
    method: 'post',
    data: {
      ...data,
      sendTime: sendTime
    }
  })
}

// 该用户熊猫系统菜单
export const routes = () => {
  return axios({
    url: '/routes',
    method: 'get',
  })
}

export const summary = (params) => {
  return axios({
    isDebounce: true,
    url: api.summary,
    method: 'get',
    params,
  })
}

export const uploadRecord = (data) => {
  return axios({
    headers: {
      "Content-Type": "multipart/form-data",
    },
    timeout: 3 * 60 * 1000,
    url: api.uploadRecord,
    method: 'post',
    data,
  })
}

// 高德搜索地址
export const searchAddress = (params) => {
  return axios({
    url: "https://restapi.amap.com/v3/place/text?parameters",
    method: 'get',
    showLoading: true,
    params: {
      key: "f97f327da6cec27ba330a28b275d4504",
      ...params,
    },
  })
}

// 城市列表
export const deptList = () => {
  return axios({
    url: api.deptList,
    method: 'get',
  })
}
